<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pypln.pypln.workers.base</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/pypln">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;pypln ::
        <a href="pypln.pypln-module.html">Package&nbsp;pypln</a> ::
        <a href="pypln.pypln.workers-module.html">Package&nbsp;workers</a> ::
        Module&nbsp;base
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="pypln.pypln.workers.base-module.html">Module pypln.pypln.workers.base</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring">Base classes for workers</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">zmq</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">time</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">os</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-comment">#context = zmq.Context()</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-comment">#TODO: move here common methods and attributes of workers</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-comment">#TODO: get port numbers from package level PORTS variable</tt> </tt>
<a name="BaseWorker"></a><div id="BaseWorker-def"><a name="L13"></a><tt class="py-lineno"> 13</tt> <a class="py-toggle" href="#" id="BaseWorker-toggle" onclick="return toggle('BaseWorker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html">BaseWorker</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="BaseWorker-expanded"><a name="BaseWorker.__init__"></a><div id="BaseWorker.__init__-def"><a name="L14"></a><tt class="py-lineno"> 14</tt> <a class="py-toggle" href="#" id="BaseWorker.__init__-toggle" onclick="return toggle('BaseWorker.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">subport</tt><tt class="py-op">=</tt><tt class="py-number">5560</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="BaseWorker.__init__-expanded"><a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">subport</tt> <tt class="py-op">=</tt> <tt class="py-number">5560</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">stayalive</tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
</div><a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"> </tt>
<a name="BaseWorker.__call__"></a><div id="BaseWorker.__call__-def"><a name="L18"></a><tt class="py-lineno"> 18</tt> <a class="py-toggle" href="#" id="BaseWorker.__call__-toggle" onclick="return toggle('BaseWorker.__call__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html#__call__">__call__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker.__call__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="BaseWorker.__call__-expanded"><a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-docstring">        worker instances can be started by direct calling</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-docstring">        This is for compatibility with multiprocessing.Process</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line">        <tt class="py-comment"># Initialization had to be moved into __call__ for compatibility with multiprocessing.</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line">        <tt class="py-comment"># This way the sockets are created in the child process, when the worked is activated</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-0" class="py-name" targets="Variable pypln.pypln.Monitors.graphite_monitor.context=pypln.pypln.Monitors.graphite_monitor-module.html#context,Variable pypln.pypln.servers.ventilator.context=pypln.pypln.servers.ventilator-module.html#context,Variable pypln.pypln.sinks.dummy_sink.context=pypln.pypln.sinks.dummy_sink-module.html#context,Variable pypln.pypln.sinks.mongo_insert_sink.context=pypln.pypln.sinks.mongo_insert_sink-module.html#context,Variable pypln.pypln.sinks.mongo_update_sink.context=pypln.pypln.sinks.mongo_update_sink-module.html#context,Variable pypln.pypln.sinks.raw_document_sink.context=pypln.pypln.sinks.raw_document_sink-module.html#context,Variable pypln.pypln.workers.enc_detect_worker.context=pypln.pypln.workers.enc_detect_worker-module.html#context,Variable pypln.pypln.workers.mime_detect_worker.context=pypln.pypln.workers.mime_detect_worker-module.html#context,Variable pypln.pypln.workers.palavras_worker.context=pypln.pypln.workers.palavras_worker-module.html#context,Variable pypln.pypln.workers.parser_worker.context=pypln.pypln.workers.parser_worker-module.html#context,Variable pypln.pypln.workers.pdfconv_worker.context=pypln.pypln.workers.pdfconv_worker-module.html#context,Variable pypln.pypln.workers.tagger_worker.context=pypln.pypln.workers.tagger_worker-module.html#context"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-0', 'context', 'link-0');">context</a></tt> <tt class="py-op">=</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">Context</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pid</tt> <tt class="py-op">=</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">getpid</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line">        <tt class="py-comment"># Set up a SUB channel to get information about task queue completion</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-1" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-1', 'context', 'link-0');">context</a></tt><tt class="py-op">.</tt><tt class="py-name">socket</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">SUB</tt><tt class="py-op">)</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">connect</tt><tt class="py-op">(</tt><tt class="py-string">"tcp://127.0.0.1:%s"</tt><tt class="py-op">%</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">subport</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">setsockopt</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">SUBSCRIBE</tt><tt class="py-op">,</tt><tt class="py-string">"sink-finished"</tt><tt class="py-op">)</tt> <tt class="py-comment">#only sub to msgs starting with "sink-finished"</tt> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Method pypln.pypln.sinks.base.BaseSink.start()=pypln.pypln.sinks.base.BaseSink-class.html#start,Method pypln.pypln.sinks.dummy_sink.DummySink.start()=pypln.pypln.sinks.dummy_sink.DummySink-class.html#start,Method pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start()=pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink-class.html#start,Method pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start()=pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink-class.html#start,Method pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start()=pypln.pypln.sinks.raw_document_sink.RawDocumentSink-class.html#start,Method pypln.pypln.workers.base.BaseWorker.start()=pypln.pypln.workers.base.BaseWorker-class.html#start,Method pypln.pypln.workers.base.PushPullWorker.start()=pypln.pypln.workers.base.PushPullWorker-class.html#start,Method pypln.pypln.workers.dummy_worker.DummyWorker.start()=pypln.pypln.workers.dummy_worker.DummyWorker-class.html#start,Method pypln.pypln.workers.enc_detect_worker.EncodingWorker.start()=pypln.pypln.workers.enc_detect_worker.EncodingWorker-class.html#start,Method pypln.pypln.workers.mime_detect_worker.MimeWorker.start()=pypln.pypln.workers.mime_detect_worker.MimeWorker-class.html#start,Method pypln.pypln.workers.palavras_worker.Palavras_worker.start()=pypln.pypln.workers.palavras_worker.Palavras_worker-class.html#start,Method pypln.pypln.workers.parser_worker.ParserWorker.start()=pypln.pypln.workers.parser_worker.ParserWorker-class.html#start"><a title="pypln.pypln.sinks.base.BaseSink.start
pypln.pypln.sinks.dummy_sink.DummySink.start
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start
pypln.pypln.workers.base.BaseWorker.start
pypln.pypln.workers.base.PushPullWorker.start
pypln.pypln.workers.dummy_worker.DummyWorker.start
pypln.pypln.workers.enc_detect_worker.EncodingWorker.start
pypln.pypln.workers.mime_detect_worker.MimeWorker.start
pypln.pypln.workers.palavras_worker.Palavras_worker.start
pypln.pypln.workers.parser_worker.ParserWorker.start" class="py-name" href="#" onclick="return doclink('link-2', 'start', 'link-2');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"> </tt>
<a name="BaseWorker.stop"></a><div id="BaseWorker.stop-def"><a name="L34"></a><tt class="py-lineno"> 34</tt> <a class="py-toggle" href="#" id="BaseWorker.stop-toggle" onclick="return toggle('BaseWorker.stop');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html#stop">stop</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker.stop-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="BaseWorker.stop-expanded"><a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">stayalive</tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
</div><a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">         </tt>
<a name="BaseWorker.start"></a><div id="BaseWorker.start-def"><a name="L37"></a><tt class="py-lineno"> 37</tt> <a class="py-toggle" href="#" id="BaseWorker.start-toggle" onclick="return toggle('BaseWorker.start');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html#start">start</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker.start-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="BaseWorker.start-expanded"><a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">        Starts listening on receiver port for messages</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">        this method maybe overloaded by specific workers</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">        Runs forever until msg is received on the self.sub channel</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">        <tt class="py-comment"># Process tasks forever</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">        <tt class="py-keyword">print</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pid</tt><tt class="py-op">,</tt>  <tt class="py-string">" starting"</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">        <tt class="py-name">msgproc</tt> <tt class="py-op">=</tt> <tt class="py-number">0</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">        <tt class="py-keyword">while</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">stayalive</tt><tt class="py-op">:</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">            <tt class="py-name">socks</tt> <tt class="py-op">=</tt> <tt class="py-name">dict</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Variable pypln.pypln.Monitors.graphite_monitor.poller=pypln.pypln.Monitors.graphite_monitor-module.html#poller"><a title="pypln.pypln.Monitors.graphite_monitor.poller" class="py-name" href="#" onclick="return doclink('link-3', 'poller', 'link-3');">poller</a></tt><tt class="py-op">.</tt><tt class="py-name">poll</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt> <tt class="py-keyword">in</tt> <tt class="py-name">socks</tt> <tt class="py-keyword">and</tt> <tt class="py-name">socks</tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">:</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">                <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">.</tt><tt class="py-name">recv_json</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-string">'jobid'</tt> <tt class="py-keyword">in</tt> <tt class="py-name">msg</tt><tt class="py-op">:</tt> <tt class="py-comment"># startup message</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">                    <tt class="py-keyword">print</tt> <tt class="py-string">"starting job %s"</tt><tt class="py-op">%</tt><tt class="py-name">msg</tt><tt class="py-op">[</tt><tt class="py-string">'jobid'</tt><tt class="py-op">]</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sender</tt><tt class="py-op">.</tt><tt class="py-name">send_json</tt><tt class="py-op">(</tt><tt class="py-op">{</tt><tt class="py-string">'fail'</tt><tt class="py-op">:</tt><tt class="py-number">1</tt><tt class="py-op">}</tt><tt class="py-op">)</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name" targets="Method pypln.pypln.sinks.base.BaseSink.process()=pypln.pypln.sinks.base.BaseSink-class.html#process,Method pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.process()=pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink-class.html#process,Method pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.process()=pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink-class.html#process,Method pypln.pypln.sinks.raw_document_sink.RawDocumentSink.process()=pypln.pypln.sinks.raw_document_sink.RawDocumentSink-class.html#process,Method pypln.pypln.workers.base.BaseWorker.process()=pypln.pypln.workers.base.BaseWorker-class.html#process,Method pypln.pypln.workers.base.PushPullWorker.process()=pypln.pypln.workers.base.PushPullWorker-class.html#process,Method pypln.pypln.workers.dummy_worker.DummyWorker.process()=pypln.pypln.workers.dummy_worker.DummyWorker-class.html#process,Method pypln.pypln.workers.enc_detect_worker.EncodingWorker.process()=pypln.pypln.workers.enc_detect_worker.EncodingWorker-class.html#process,Method pypln.pypln.workers.highlighter_worker.HighlighterWorker.process()=pypln.pypln.workers.highlighter_worker.HighlighterWorker-class.html#process,Method pypln.pypln.workers.mime_detect_worker.MimeWorker.process()=pypln.pypln.workers.mime_detect_worker.MimeWorker-class.html#process,Method pypln.pypln.workers.palavras_worker.Palavras_worker.process()=pypln.pypln.workers.palavras_worker.Palavras_worker-class.html#process,Method pypln.pypln.workers.parser_worker.ParserWorker.process()=pypln.pypln.workers.parser_worker.ParserWorker-class.html#process,Method pypln.pypln.workers.pdfconv_worker.PDFConverterWorker.process()=pypln.pypln.workers.pdfconv_worker.PDFConverterWorker-class.html#process,Method pypln.pypln.workers.tagger_worker.POSTaggerWorker.process()=pypln.pypln.workers.tagger_worker.POSTaggerWorker-class.html#process"><a title="pypln.pypln.sinks.base.BaseSink.process
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.process
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.process
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.process
pypln.pypln.workers.base.BaseWorker.process
pypln.pypln.workers.base.PushPullWorker.process
pypln.pypln.workers.dummy_worker.DummyWorker.process
pypln.pypln.workers.enc_detect_worker.EncodingWorker.process
pypln.pypln.workers.highlighter_worker.HighlighterWorker.process
pypln.pypln.workers.mime_detect_worker.MimeWorker.process
pypln.pypln.workers.palavras_worker.Palavras_worker.process
pypln.pypln.workers.parser_worker.ParserWorker.process
pypln.pypln.workers.pdfconv_worker.PDFConverterWorker.process
pypln.pypln.workers.tagger_worker.POSTaggerWorker.process" class="py-name" href="#" onclick="return doclink('link-4', 'process', 'link-4');">process</a></tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">                <tt class="py-name">msgproc</tt> <tt class="py-op">+=</tt> <tt class="py-number">1</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt> <tt class="py-keyword">in</tt> <tt class="py-name">socks</tt> <tt class="py-keyword">and</tt> <tt class="py-name">socks</tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">:</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">                <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">recv</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">                <tt class="py-keyword">print</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pid</tt><tt class="py-op">,</tt> <tt class="py-string">" Done after processing %s messages"</tt><tt class="py-op">%</tt><tt class="py-name">msgproc</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">                <tt class="py-keyword">break</tt> </tt>
</div><a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">             </tt>
<a name="BaseWorker.process"></a><div id="BaseWorker.process-def"><a name="L61"></a><tt class="py-lineno"> 61</tt> <a class="py-toggle" href="#" id="BaseWorker.process-toggle" onclick="return toggle('BaseWorker.process');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.BaseWorker-class.html#process">process</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">msg</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="BaseWorker.process-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="BaseWorker.process-expanded"><a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-docstring">        This method must be overloaded by derived workers</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">NotImplementedError</tt> </tt>
</div></div><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">     </tt>
<a name="PushPullWorker"></a><div id="PushPullWorker-def"><a name="L67"></a><tt class="py-lineno"> 67</tt> <a class="py-toggle" href="#" id="PushPullWorker-toggle" onclick="return toggle('PushPullWorker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="pypln.pypln.workers.base.PushPullWorker-class.html">PushPullWorker</a><tt class="py-op">(</tt><tt class="py-base-class">BaseWorker</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PushPullWorker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="PushPullWorker-expanded"><a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring">    Base class for worker which user the push-pull protocol</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="PushPullWorker.__init__"></a><div id="PushPullWorker.__init__-def"><a name="L71"></a><tt class="py-lineno"> 71</tt> <a class="py-toggle" href="#" id="PushPullWorker.__init__-toggle" onclick="return toggle('PushPullWorker.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.PushPullWorker-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">pullport</tt><tt class="py-op">=</tt><tt class="py-number">5557</tt><tt class="py-op">,</tt> <tt class="py-param">pushport</tt><tt class="py-op">=</tt><tt class="py-number">5558</tt><tt class="py-op">,</tt> <tt class="py-param">subport</tt><tt class="py-op">=</tt><tt class="py-number">5560</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PushPullWorker.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PushPullWorker.__init__-expanded"><a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pullport</tt> <tt class="py-op">=</tt> <tt class="py-name">pullport</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pushport</tt> <tt class="py-op">=</tt> <tt class="py-name">pushport</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">subport</tt> <tt class="py-op">=</tt> <tt class="py-name">subport</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">        <tt class="py-comment"># call base class constructor</tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">        <tt id="link-5" class="py-name" targets="Class pypln.pypln.workers.base.BaseWorker=pypln.pypln.workers.base.BaseWorker-class.html"><a title="pypln.pypln.workers.base.BaseWorker" class="py-name" href="#" onclick="return doclink('link-5', 'BaseWorker', 'link-5');">BaseWorker</a></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Method pypln.apps.baseapp.TaskVentilator.__init__()=pypln.apps.baseapp.TaskVentilator-class.html#__init__,Method pypln.pypln.servers.ventilator.Ventilator.__init__()=pypln.pypln.servers.ventilator.Ventilator-class.html#__init__,Method pypln.pypln.sinks.base.BaseSink.__init__()=pypln.pypln.sinks.base.BaseSink-class.html#__init__,Method pypln.pypln.stores.filestor.FS.__init__()=pypln.pypln.stores.filestor.FS-class.html#__init__,Method pypln.pypln.stores.mongocorpus.MongoDBCorpusReader.__init__()=pypln.pypln.stores.mongocorpus.MongoDBCorpusReader-class.html#__init__,Method pypln.pypln.stores.mongocorpus.MongoDBLazySequence.__init__()=pypln.pypln.stores.mongocorpus.MongoDBLazySequence-class.html#__init__,Method pypln.pypln.workers.base.BaseWorker.__init__()=pypln.pypln.workers.base.BaseWorker-class.html#__init__,Method pypln.pypln.workers.base.PushPullWorker.__init__()=pypln.pypln.workers.base.PushPullWorker-class.html#__init__"><a title="pypln.apps.baseapp.TaskVentilator.__init__
pypln.pypln.servers.ventilator.Ventilator.__init__
pypln.pypln.sinks.base.BaseSink.__init__
pypln.pypln.stores.filestor.FS.__init__
pypln.pypln.stores.mongocorpus.MongoDBCorpusReader.__init__
pypln.pypln.stores.mongocorpus.MongoDBLazySequence.__init__
pypln.pypln.workers.base.BaseWorker.__init__
pypln.pypln.workers.base.PushPullWorker.__init__" class="py-name" href="#" onclick="return doclink('link-6', '__init__', 'link-6');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt><tt class="py-name">subport</tt><tt class="py-op">=</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">subport</tt><tt class="py-op">)</tt> </tt>
</div><a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">         </tt>
<a name="PushPullWorker.__call__"></a><div id="PushPullWorker.__call__-def"><a name="L81"></a><tt class="py-lineno"> 81</tt> <a class="py-toggle" href="#" id="PushPullWorker.__call__-toggle" onclick="return toggle('PushPullWorker.__call__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.PushPullWorker-class.html#__call__">__call__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-param">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-param">kwargs</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PushPullWorker.__call__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PushPullWorker.__call__-expanded"><a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"><tt class="py-docstring">        worker instances can be started by direct calling</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-docstring">        This is for compatibility with multiprocessing.Process</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-7', 'context', 'link-0');">context</a></tt> <tt class="py-op">=</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">Context</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pid</tt> <tt class="py-op">=</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">getpid</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">        <tt class="py-comment"># Set up a SUB channel to get information about task queue completion</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-8', 'context', 'link-0');">context</a></tt><tt class="py-op">.</tt><tt class="py-name">socket</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">SUB</tt><tt class="py-op">)</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">connect</tt><tt class="py-op">(</tt><tt class="py-string">"tcp://127.0.0.1:%s"</tt><tt class="py-op">%</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">subport</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">setsockopt</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">SUBSCRIBE</tt><tt class="py-op">,</tt><tt class="py-string">"sink-finished"</tt><tt class="py-op">)</tt> <tt class="py-comment">#only sub to msgs starting with "sink-finished"</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt class="py-comment"># Socket to receive messages on</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-9', 'context', 'link-0');">context</a></tt><tt class="py-op">.</tt><tt class="py-name">socket</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">PULL</tt><tt class="py-op">)</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">.</tt><tt class="py-name">connect</tt><tt class="py-op">(</tt><tt class="py-string">"tcp://127.0.0.1:%s"</tt><tt class="py-op">%</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pullport</tt><tt class="py-op">)</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">        <tt class="py-comment"># Socket to send messages to</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sender</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.context
pypln.pypln.servers.ventilator.context
pypln.pypln.sinks.dummy_sink.context
pypln.pypln.sinks.mongo_insert_sink.context
pypln.pypln.sinks.mongo_update_sink.context
pypln.pypln.sinks.raw_document_sink.context
pypln.pypln.workers.enc_detect_worker.context
pypln.pypln.workers.mime_detect_worker.context
pypln.pypln.workers.palavras_worker.context
pypln.pypln.workers.parser_worker.context
pypln.pypln.workers.pdfconv_worker.context
pypln.pypln.workers.tagger_worker.context" class="py-name" href="#" onclick="return doclink('link-10', 'context', 'link-0');">context</a></tt><tt class="py-op">.</tt><tt class="py-name">socket</tt><tt class="py-op">(</tt><tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">PUSH</tt><tt class="py-op">)</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sender</tt><tt class="py-op">.</tt><tt class="py-name">connect</tt><tt class="py-op">(</tt><tt class="py-string">"tcp://127.0.0.1:%s"</tt><tt class="py-op">%</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pushport</tt><tt class="py-op">)</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">        <tt class="py-comment"># Initialize poll set to listen on two channels at once</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.poller" class="py-name" href="#" onclick="return doclink('link-11', 'poller', 'link-3');">poller</a></tt> <tt class="py-op">=</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">Poller</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-12" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.poller" class="py-name" href="#" onclick="return doclink('link-12', 'poller', 'link-3');">poller</a></tt><tt class="py-op">.</tt><tt class="py-name">register</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">,</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">)</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-13" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.poller" class="py-name" href="#" onclick="return doclink('link-13', 'poller', 'link-3');">poller</a></tt><tt class="py-op">.</tt><tt class="py-name">register</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">,</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">)</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">        <tt class="py-comment"># start listening</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-14" class="py-name"><a title="pypln.pypln.sinks.base.BaseSink.start
pypln.pypln.sinks.dummy_sink.DummySink.start
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start
pypln.pypln.workers.base.BaseWorker.start
pypln.pypln.workers.base.PushPullWorker.start
pypln.pypln.workers.dummy_worker.DummyWorker.start
pypln.pypln.workers.enc_detect_worker.EncodingWorker.start
pypln.pypln.workers.mime_detect_worker.MimeWorker.start
pypln.pypln.workers.palavras_worker.Palavras_worker.start
pypln.pypln.workers.parser_worker.ParserWorker.start" class="py-name" href="#" onclick="return doclink('link-14', 'start', 'link-2');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line"> </tt>
<a name="PushPullWorker.start"></a><div id="PushPullWorker.start-def"><a name="L105"></a><tt class="py-lineno">105</tt> <a class="py-toggle" href="#" id="PushPullWorker.start-toggle" onclick="return toggle('PushPullWorker.start');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.PushPullWorker-class.html#start">start</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PushPullWorker.start-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PushPullWorker.start-expanded"><a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line"><tt class="py-docstring">        Starts listening on receiver port for messages</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line"><tt class="py-docstring">        this method maybe overloaded by specific workers</tt> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">         </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">        <tt class="py-keyword">while</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">stayalive</tt><tt class="py-op">:</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">            <tt class="py-name">socks</tt> <tt class="py-op">=</tt> <tt class="py-name">dict</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="pypln.pypln.Monitors.graphite_monitor.poller" class="py-name" href="#" onclick="return doclink('link-15', 'poller', 'link-3');">poller</a></tt><tt class="py-op">.</tt><tt class="py-name">poll</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt> <tt class="py-keyword">in</tt> <tt class="py-name">socks</tt> <tt class="py-keyword">and</tt> <tt class="py-name">socks</tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">:</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">                <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">receiver</tt><tt class="py-op">.</tt><tt class="py-name">recv_json</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-string">'jobid'</tt> <tt class="py-keyword">in</tt> <tt class="py-name">msg</tt><tt class="py-op">:</tt> <tt class="py-comment"># startup message</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">                    <tt class="py-keyword">continue</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name"><a title="pypln.pypln.sinks.base.BaseSink.process
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.process
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.process
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.process
pypln.pypln.workers.base.BaseWorker.process
pypln.pypln.workers.base.PushPullWorker.process
pypln.pypln.workers.dummy_worker.DummyWorker.process
pypln.pypln.workers.enc_detect_worker.EncodingWorker.process
pypln.pypln.workers.highlighter_worker.HighlighterWorker.process
pypln.pypln.workers.mime_detect_worker.MimeWorker.process
pypln.pypln.workers.palavras_worker.Palavras_worker.process
pypln.pypln.workers.parser_worker.ParserWorker.process
pypln.pypln.workers.pdfconv_worker.PDFConverterWorker.process
pypln.pypln.workers.tagger_worker.POSTaggerWorker.process" class="py-name" href="#" onclick="return doclink('link-16', 'process', 'link-4');">process</a></tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt> <tt class="py-keyword">in</tt> <tt class="py-name">socks</tt> <tt class="py-keyword">and</tt> <tt class="py-name">socks</tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-name">zmq</tt><tt class="py-op">.</tt><tt class="py-name">POLLIN</tt><tt class="py-op">:</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">                <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">.</tt><tt class="py-name">recv</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">                <tt class="py-keyword">print</tt> <tt class="py-name">msg</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">                <tt class="py-keyword">break</tt> </tt>
</div><a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line"> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line"> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">     </tt>
<a name="PushPullWorker.process"></a><div id="PushPullWorker.process-def"><a name="L125"></a><tt class="py-lineno">125</tt> <a class="py-toggle" href="#" id="PushPullWorker.process-toggle" onclick="return toggle('PushPullWorker.process');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.pypln.workers.base.PushPullWorker-class.html#process">process</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">msg</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PushPullWorker.process-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PushPullWorker.process-expanded"><a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line"><tt class="py-docstring">        This method must be overloaded by derived workers</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">        <tt class="py-comment"># Simple progress indicator for the viewer</tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line">        <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">stdout</tt><tt class="py-op">.</tt><tt class="py-name">write</tt><tt class="py-op">(</tt><tt class="py-string">','</tt><tt class="py-op">)</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">        <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">stdout</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name" targets="Method pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.flush()=pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink-class.html#flush"><a title="pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.flush" class="py-name" href="#" onclick="return doclink('link-17', 'flush', 'link-17');">flush</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line">        <tt class="py-comment"># Send results to sink</tt> </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">sender</tt><tt class="py-op">.</tt><tt class="py-name">send_json</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/pypln">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sat Mar 31 10:39:42 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
